From 5befb9b74790a99aec5514ad8f8784a4fb085288 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Fri, 16 Jan 2015 14:42:54 -0800 Subject: [PATCH] SpecialMovepage: Convert form to use OOUI controls Recreated the form with OOUI widgets. This required putting together ComplexTitleInputWidget to handle the split namespace+title field on this page. Bug: T86865 Change-Id: Ice69df851137e3454ae2c9f4c75494b18cf8a75a --- autoload.php | 1 + includes/specials/SpecialMovepage.php | 323 +++++++++--------- includes/widget/ComplexTitleInputWidget.php | 67 ++++ includes/widget/NamespaceInputWidget.php | 9 +- resources/Resources.php | 11 +- .../mediawiki.special.movePage.css | 8 + .../mediawiki.special.movePage.js | 5 +- ...w.widgets.ComplexTitleInputWidget.base.css | 20 ++ .../mw.widgets.ComplexTitleInputWidget.js | 63 ++++ .../mw.widgets.NamespaceInputWidget.js | 6 +- .../mw.widgets.TitleInputWidget.js | 20 ++ 11 files changed, 367 insertions(+), 166 deletions(-) create mode 100644 includes/widget/ComplexTitleInputWidget.php create mode 100644 resources/src/mediawiki.special/mediawiki.special.movePage.css create mode 100644 resources/src/mediawiki.widgets/mw.widgets.ComplexTitleInputWidget.base.css create mode 100644 resources/src/mediawiki.widgets/mw.widgets.ComplexTitleInputWidget.js diff --git a/autoload.php b/autoload.php index 82a45b49d5..d91b7042d1 100644 --- a/autoload.php +++ b/autoload.php @@ -762,6 +762,7 @@ $wgAutoloadLocalClasses = array( 'MediaWiki\\Logger\\NullSpi' => __DIR__ . '/includes/debug/logger/NullSpi.php', 'MediaWiki\\Logger\\Spi' => __DIR__ . '/includes/debug/logger/Spi.php', 'MediaWiki\\Widget\\ComplexNamespaceInputWidget' => __DIR__ . '/includes/widget/ComplexNamespaceInputWidget.php', + 'MediaWiki\\Widget\\ComplexTitleInputWidget' => __DIR__ . '/includes/widget/ComplexTitleInputWidget.php', 'MediaWiki\\Widget\\NamespaceInputWidget' => __DIR__ . '/includes/widget/NamespaceInputWidget.php', 'MediaWiki\\Widget\\TitleInputWidget' => __DIR__ . '/includes/widget/TitleInputWidget.php', 'MediaWiki\\Widget\\UserInputWidget' => __DIR__ . '/includes/widget/UserInputWidget.php', diff --git a/includes/specials/SpecialMovepage.php b/includes/specials/SpecialMovepage.php index eb8a274e8c..8091f1b0dc 100644 --- a/includes/specials/SpecialMovepage.php +++ b/includes/specials/SpecialMovepage.php @@ -147,6 +147,7 @@ class MovePageForm extends UnlistedSpecialPage { $out = $this->getOutput(); $out->setPageTitle( $this->msg( 'move-page', $this->oldTitle->getPrefixedText() ) ); $out->addModules( 'mediawiki.special.movePage' ); + $out->addModuleStyles( 'mediawiki.special.movePage.styles' ); $this->addHelpLink( 'Help:Moving a page' ); $newTitle = $this->newTitle; @@ -290,7 +291,6 @@ class MovePageForm extends UnlistedSpecialPage { // is enforced in the mediawiki.special.movePage module $immovableNamespaces = array(); - foreach ( array_keys( $this->getLanguage()->getNamespaces() ) as $nsId ) { if ( !MWNamespace::isMovable( $nsId ) ) { $immovableNamespaces[] = $nsId; @@ -299,202 +299,207 @@ class MovePageForm extends UnlistedSpecialPage { $handler = ContentHandler::getForTitle( $this->oldTitle ); - $out->addHTML( - Xml::openElement( - 'form', - array( - 'method' => 'post', - 'action' => $this->getPageTitle()->getLocalURL( 'action=submit' ), - 'id' => 'movepage' - ) - ) . - Xml::openElement( 'fieldset' ) . - Xml::element( 'legend', null, $this->msg( 'move-page-legend' )->text() ) . - Xml::openElement( 'table', array( 'id' => 'mw-movepage-table' ) ) + $out->enableOOUI(); + $fields = array(); + + $fields[] = new OOUI\FieldLayout( + new OOUI\LabelWidget( array( + 'label' => new OOUI\HtmlSnippet( "$oldTitleLink" ) + ) ), + array( + 'label' => $this->msg( 'movearticle' )->text(), + 'align' => 'top', + ) ); - $out->addHTML( - " - " . - $this->msg( 'movearticle' )->escaped() . - " - - {$oldTitleLink} - - - - " . - Xml::label( $this->msg( 'newtitle' )->text(), 'wpNewTitleMain' ) . - " - " . - Html::namespaceSelector( - array( - 'selected' => $newTitle->getNamespace(), - 'exclude' => $immovableNamespaces - ), - array( 'name' => 'wpNewTitleNs', 'id' => 'wpNewTitleNs' ) - ) . - Xml::input( - 'wpNewTitleMain', - 60, - $wgContLang->recodeForEdit( $newTitle->getText() ), - array( - 'type' => 'text', - 'id' => 'wpNewTitleMain', - 'maxlength' => 255 - ) - ) . - Html::hidden( 'wpOldTitle', $this->oldTitle->getPrefixedText() ) . - " - - - " . - Xml::label( $this->msg( 'movereason' )->text(), 'wpReason' ) . - " - " . - Xml::input( 'wpReason', 60, $this->reason, array( - 'type' => 'text', - 'id' => 'wpReason', - 'maxlength' => 200, - ) ) . - " - " + $fields[] = new OOUI\FieldLayout( + new MediaWiki\Widget\ComplexTitleInputWidget( array( + 'id' => 'wpNewTitle', + 'namespace' => array( + 'id' => 'wpNewTitleNs', + 'name' => 'wpNewTitleNs', + 'value' => $newTitle->getNamespace(), + 'exclude' => $immovableNamespaces, + ), + 'title' => array( + 'id' => 'wpNewTitleMain', + 'name' => 'wpNewTitleMain', + 'value' => $wgContLang->recodeForEdit( $newTitle->getText() ), + // Inappropriate, since we're expecting the user to input a non-existent page's title + 'suggestions' => false, + ), + 'infusable' => true, + ) ), + array( + 'label' => $this->msg( 'newtitle' )->text(), + 'align' => 'top', + ) + ); + + $fields[] = new OOUI\FieldLayout( + new OOUI\TextInputWidget( array( + 'name' => 'wpReason', + 'id' => 'wpReason', + 'maxLength' => 200, + 'infusable' => true, + ) ), + array( + 'label' => $this->msg( 'movereason' )->text(), + 'align' => 'top', + ) ); if ( $considerTalk ) { - $out->addHTML( " - - - " . - Xml::checkLabel( - $this->msg( 'movetalk' )->text(), - 'wpMovetalk', - 'wpMovetalk', - $this->moveTalk - ) . - " - " + $fields[] = new OOUI\FieldLayout( + new OOUI\CheckboxInputWidget( array( + 'name' => 'wpMovetalk', + 'id' => 'wpMovetalk', + 'value' => '1', + 'selected' => $this->moveTalk, + ) ), + array( + 'label' => $this->msg( 'movetalk' )->text(), + 'align' => 'inline', + ) ); } if ( $user->isAllowed( 'suppressredirect' ) ) { if ( $handler->supportsRedirects() ) { $isChecked = $this->leaveRedirect; - $options = array(); + $isDisabled = false; } else { $isChecked = false; - $options = array( - 'disabled' => 'disabled' - ); + $isDisabled = true; } - $out->addHTML( " - - - " . - Xml::checkLabel( - $this->msg( 'move-leave-redirect' )->text(), - 'wpLeaveRedirect', - 'wpLeaveRedirect', - $isChecked, - $options - ) . - " - " + $fields[] = new OOUI\FieldLayout( + new OOUI\CheckboxInputWidget( array( + 'name' => 'wpLeaveRedirect', + 'id' => 'wpLeaveRedirect', + 'value' => '1', + 'selected' => $isChecked, + 'disabled' => $isDisabled, + ) ), + array( + 'label' => $this->msg( 'move-leave-redirect' )->text(), + 'align' => 'inline', + ) ); } if ( $hasRedirects ) { - $out->addHTML( " - - - " . - Xml::checkLabel( - $this->msg( 'fix-double-redirects' )->text(), - 'wpFixRedirects', - 'wpFixRedirects', - $this->fixRedirects - ) . - " - " + $fields[] = new OOUI\FieldLayout( + new OOUI\CheckboxInputWidget( array( + 'name' => 'wpFixRedirects', + 'id' => 'wpFixRedirects', + 'value' => '1', + 'selected' => $this->fixRedirects, + ) ), + array( + 'label' => $this->msg( 'fix-double-redirects' )->text(), + 'align' => 'inline', + ) ); } if ( $canMoveSubpage ) { $maximumMovedPages = $this->getConfig()->get( 'MaximumMovedPages' ); - $out->addHTML( " - - - " . - Xml::check( - 'wpMovesubpages', - # Don't check the box if we only have talk subpages to - # move and we aren't moving the talk page. - $this->moveSubpages && ( $this->oldTitle->hasSubpages() || $this->moveTalk ), - array( 'id' => 'wpMovesubpages' ) - ) . ' ' . - Xml::tags( - 'label', - array( 'for' => 'wpMovesubpages' ), - $this->msg( - ( $this->oldTitle->hasSubpages() - ? 'move-subpages' - : 'move-talk-subpages' ) - )->numParams( $maximumMovedPages )->params( $maximumMovedPages )->parse() - ) . - " - " + $fields[] = new OOUI\FieldLayout( + new OOUI\CheckboxInputWidget( array( + 'name' => 'wpMovesubpages', + 'id' => 'wpMovesubpages', + 'value' => '1', + # Don't check the box if we only have talk subpages to + # move and we aren't moving the talk page. + 'selected' => $this->moveSubpages && ( $this->oldTitle->hasSubpages() || $this->moveTalk ), + ) ), + array( + 'label' => new OOUI\HtmlSnippet( + $this->msg( + ( $this->oldTitle->hasSubpages() + ? 'move-subpages' + : 'move-talk-subpages' ) + )->numParams( $maximumMovedPages )->params( $maximumMovedPages )->parse() + ), + 'align' => 'inline', + ) ); } - $watchChecked = $user->isLoggedIn() && ( $this->watch || $user->getBoolOption( 'watchmoves' ) - || $user->isWatched( $this->oldTitle ) ); # Don't allow watching if user is not logged in if ( $user->isLoggedIn() ) { - $out->addHTML( " - - - " . - Xml::checkLabel( - $this->msg( 'move-watch' )->text(), - 'wpWatch', - 'watch', - $watchChecked - ) . - " - " + $watchChecked = $user->isLoggedIn() && ( $this->watch || $user->getBoolOption( 'watchmoves' ) + || $user->isWatched( $this->oldTitle ) ); + $fields[] = new OOUI\FieldLayout( + new OOUI\CheckboxInputWidget( array( + 'name' => 'wpWatch', + 'id' => 'watch', # ew + 'value' => '1', + 'selected' => $watchChecked, + ) ), + array( + 'label' => $this->msg( 'move-watch' )->text(), + 'align' => 'inline', + ) ); } if ( $confirm ) { - $out->addHTML( " - - - " . - Xml::checkLabel( - $this->msg( 'delete_and_move_confirm' )->text(), - 'wpConfirm', - 'wpConfirm' - ) . - " - " + $watchChecked = $user->isLoggedIn() && ( $this->watch || $user->getBoolOption( 'watchmoves' ) + || $user->isWatched( $this->oldTitle ) ); + $fields[] = new OOUI\FieldLayout( + new OOUI\CheckboxInputWidget( array( + 'name' => 'wpConfirm', + 'id' => 'wpConfirm', + 'value' => '1', + ) ), + array( + 'label' => $this->msg( 'delete_and_move_confirm' )->text(), + 'align' => 'inline', + ) ); } - $out->addHTML( " - - - " . - Xml::submitButton( $movepagebtn, array( 'name' => $submitVar ) ) . - " - " + $fields[] = new OOUI\FieldLayout( + new OOUI\ButtonInputWidget( array( + 'name' => $submitVar, + 'value' => $movepagebtn, + 'label' => $movepagebtn, + 'flags' => array( 'progressive', 'primary' ), + 'type' => 'submit', + ) ), + array( + 'align' => 'top', + ) + ); + + $fieldset = new OOUI\FieldsetLayout( array( + 'label' => $this->msg( 'move-page-legend' )->text(), + 'id' => 'mw-movepage-table', + 'items' => $fields, + ) ); + + $form = new OOUI\FormLayout( array( + 'method' => 'post', + 'action' => $this->getPageTitle()->getLocalURL( 'action=submit' ), + 'id' => 'movepage', + ) ); + $form->appendContent( + $fieldset, + new OOUI\HtmlSnippet( + Html::hidden( 'wpOldTitle', $this->oldTitle->getPrefixedText() ) . + Html::hidden( 'wpEditToken', $user->getEditToken() ) + ) ); $out->addHTML( - Xml::closeElement( 'table' ) . - Html::hidden( 'wpEditToken', $user->getEditToken() ) . - Xml::closeElement( 'fieldset' ) . - Xml::closeElement( 'form' ) . - "\n" + new OOUI\PanelLayout( array( + 'classes' => array( 'movepage-wrapper' ), + 'expanded' => false, + 'padded' => true, + 'framed' => true, + 'content' => $form, + ) ) ); $this->showLogFragment( $this->oldTitle ); diff --git a/includes/widget/ComplexTitleInputWidget.php b/includes/widget/ComplexTitleInputWidget.php new file mode 100644 index 0000000000..73ef54c848 --- /dev/null +++ b/includes/widget/ComplexTitleInputWidget.php @@ -0,0 +1,67 @@ + array(), + 'title' => array(), + ), + $config + ); + + // Parent constructor + parent::__construct( $config ); + + // Properties + $this->config = $config; + $this->namespace = new NamespaceInputWidget( $config['namespace'] ); + $this->title = new TitleInputWidget( array_merge( + $config['title'], + array( + // The inner TitleInputWidget shouldn't be infusable, only the ComplexTitleInputWidget itself can be. + 'infusable' => false, + 'relative' => true, + 'namespace' => isset( $config['namespace']['value'] ) ? $config['namespace']['value'] : null, + ) + ) ); + + // Initialization + $this + ->addClasses( array( 'mw-widget-complexTitleInputWidget' ) ) + ->appendContent( $this->namespace, $this->title ); + } + + protected function getJavaScriptClassName() { + return 'mw.widgets.ComplexTitleInputWidget'; + } + + public function getConfig( &$config ) { + $config['namespace'] = $this->config['namespace']; + $config['title'] = $this->config['title']; + return parent::getConfig( $config ); + } +} diff --git a/includes/widget/NamespaceInputWidget.php b/includes/widget/NamespaceInputWidget.php index a99227e6c4..696c8adf15 100644 --- a/includes/widget/NamespaceInputWidget.php +++ b/includes/widget/NamespaceInputWidget.php @@ -18,6 +18,7 @@ class NamespaceInputWidget extends \OOUI\DropdownInputWidget { * @param array $config Configuration options * @param string $config['includeAllValue'] If specified, add a "all namespaces" option to the * namespace dropdown, and use this as the input value for it + * @param number[] $config['exclude'] List of namespace numbers to exclude from the selector */ public function __construct( array $config = array() ) { // Configuration initialization @@ -28,14 +29,17 @@ class NamespaceInputWidget extends \OOUI\DropdownInputWidget { // Properties $this->includeAllValue = isset( $config['includeAllValue'] ) ? $config['includeAllValue'] : null; + $this->exclude = isset( $config['exclude'] ) ? $config['exclude'] : array(); // Initialization $this->addClasses( array( 'mw-widget-namespaceInputWidget' ) ); } protected function getNamespaceDropdownOptions( array $config ) { - $namespaceOptionsParams = isset( $config['includeAllValue'] ) ? - array( 'all' => $config['includeAllValue'] ) : array(); + $namespaceOptionsParams = array( + 'all' => isset( $config['includeAllValue'] ) ? $config['includeAllValue'] : null, + 'exclude' => isset( $config['exclude'] ) ? $config['exclude'] : null + ); $namespaceOptions = \Html::namespaceSelectorOptions( $namespaceOptionsParams ); $options = array(); @@ -55,6 +59,7 @@ class NamespaceInputWidget extends \OOUI\DropdownInputWidget { public function getConfig( &$config ) { $config['includeAllValue'] = $this->includeAllValue; + $config['exclude'] = $this->exclude; // Skip DropdownInputWidget's getConfig(), we don't need 'options' config return \OOUI\InputWidget::getConfig( $config ); } diff --git a/resources/Resources.php b/resources/Resources.php index e21deb9d98..8579d05a80 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -1567,7 +1567,14 @@ return array( ), 'mediawiki.special.movePage' => array( 'scripts' => 'resources/src/mediawiki.special/mediawiki.special.movePage.js', - 'dependencies' => 'jquery.byteLimit', + 'dependencies' => array( + 'jquery.byteLimit', + 'mediawiki.widgets', + ), + ), + 'mediawiki.special.movePage.styles' => array( + 'styles' => 'resources/src/mediawiki.special/mediawiki.special.movePage.css', + 'position' => 'top', ), 'mediawiki.special.pageLanguage' => array( 'scripts' => 'resources/src/mediawiki.special/mediawiki.special.pageLanguage.js', @@ -1845,6 +1852,7 @@ return array( 'resources/src/mediawiki.widgets/mw.widgets.NamespaceInputWidget.js', 'resources/src/mediawiki.widgets/mw.widgets.ComplexNamespaceInputWidget.js', 'resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js', + 'resources/src/mediawiki.widgets/mw.widgets.ComplexTitleInputWidget.js', 'resources/src/mediawiki.widgets/mw.widgets.TitleOptionWidget.js', 'resources/src/mediawiki.widgets/mw.widgets.UserInputWidget.js', ), @@ -1885,6 +1893,7 @@ return array( 'skinStyles' => array( 'default' => array( 'resources/src/mediawiki.widgets/mw.widgets.ComplexNamespaceInputWidget.base.css', + 'resources/src/mediawiki.widgets/mw.widgets.ComplexTitleInputWidget.base.css', ), ), 'position' => 'top', diff --git a/resources/src/mediawiki.special/mediawiki.special.movePage.css b/resources/src/mediawiki.special/mediawiki.special.movePage.css new file mode 100644 index 0000000000..dd1c2aad05 --- /dev/null +++ b/resources/src/mediawiki.special/mediawiki.special.movePage.css @@ -0,0 +1,8 @@ +/*! + * Styles for Special:MovePage + */ + +.movepage-wrapper { + width: 50em; + margin: 1em 0; +} diff --git a/resources/src/mediawiki.special/mediawiki.special.movePage.js b/resources/src/mediawiki.special/mediawiki.special.movePage.js index 7e56050d86..6d88c51c5a 100644 --- a/resources/src/mediawiki.special/mediawiki.special.movePage.js +++ b/resources/src/mediawiki.special/mediawiki.special.movePage.js @@ -1,6 +1,7 @@ /*! * JavaScript for Special:MovePage */ -jQuery( function ( $ ) { - $( '#wpReason, #wpNewTitleMain' ).byteLimit(); +jQuery( function () { + OO.ui.infuse( 'wpNewTitle' ); + OO.ui.infuse( 'wpReason' ).$input.byteLimit(); } ); diff --git a/resources/src/mediawiki.widgets/mw.widgets.ComplexTitleInputWidget.base.css b/resources/src/mediawiki.widgets/mw.widgets.ComplexTitleInputWidget.base.css new file mode 100644 index 0000000000..73a50d8fec --- /dev/null +++ b/resources/src/mediawiki.widgets/mw.widgets.ComplexTitleInputWidget.base.css @@ -0,0 +1,20 @@ +/*! + * MediaWiki Widgets - base ComplexTitleInputWidget styles. + * + * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt + * @license The MIT License (MIT); see LICENSE.txt + */ + +.mw-widget-complexTitleInputWidget .mw-widget-namespaceInputWidget, +.mw-widget-complexTitleInputWidget .mw-widget-titleInputWidget { + display: inline-block; +} + +.mw-widget-complexTitleInputWidget .mw-widget-namespaceInputWidget { + max-width: 20em; + margin-right: 0.5em; +} + +.mw-widget-complexTitleInputWidget .mw-widget-titleInputWidget { + max-width: 29.5em; +} diff --git a/resources/src/mediawiki.widgets/mw.widgets.ComplexTitleInputWidget.js b/resources/src/mediawiki.widgets/mw.widgets.ComplexTitleInputWidget.js new file mode 100644 index 0000000000..0c6c15e475 --- /dev/null +++ b/resources/src/mediawiki.widgets/mw.widgets.ComplexTitleInputWidget.js @@ -0,0 +1,63 @@ +/*! + * MediaWiki Widgets - ComplexTitleInputWidget class. + * + * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt + * @license The MIT License (MIT); see LICENSE.txt + */ +( function ( $, mw ) { + + /** + * Like TitleInputWidget, but the namespace has to be input through a separate dropdown field. + * + * @class + * @extends OO.ui.Widget + * + * @constructor + * @param {Object} [config] Configuration options + * @cfg {Object} namespace Configuration for the NamespaceInputWidget dropdown with list of + * namespaces + * @cfg {Object} title Configuration for the TitleInputWidget text field + */ + mw.widgets.ComplexTitleInputWidget = function MwWidgetsComplexTitleInputWidget( config ) { + // Parent constructor + mw.widgets.ComplexTitleInputWidget.parent.call( this, config ); + + // Properties + this.namespace = new mw.widgets.NamespaceInputWidget( config.namespace ); + this.title = new mw.widgets.TitleInputWidget( $.extend( + {}, + config.title, + { + relative: true, + namespace: config.namespace.value || null + } + ) ); + + // Events + this.namespace.connect( this, { change: 'updateTitleNamespace' } ); + + // Initialization + this.$element + .addClass( 'mw-widget-complexTitleInputWidget' ) + .append( + this.namespace.$element, + this.title.$element + ); + this.updateTitleNamespace(); + }; + + /* Setup */ + + OO.inheritClass( mw.widgets.ComplexTitleInputWidget, OO.ui.Widget ); + + /* Methods */ + + /** + * Update the namespace to use for search suggestions of the title when the value of namespace + * dropdown changes. + */ + mw.widgets.ComplexTitleInputWidget.prototype.updateTitleNamespace = function () { + this.title.setNamespace( Number( this.namespace.getValue() ) ); + }; + +}( jQuery, mediaWiki ) ); diff --git a/resources/src/mediawiki.widgets/mw.widgets.NamespaceInputWidget.js b/resources/src/mediawiki.widgets/mw.widgets.NamespaceInputWidget.js index ef42dc1e07..4f1b874991 100644 --- a/resources/src/mediawiki.widgets/mw.widgets.NamespaceInputWidget.js +++ b/resources/src/mediawiki.widgets/mw.widgets.NamespaceInputWidget.js @@ -14,7 +14,8 @@ * * @constructor * @param {Object} [config] Configuration options - * @cfg {string|null} includeAllValue Value for "all namespaces" option, if any + * @cfg {string|null} [includeAllValue] Value for "all namespaces" option, if any + * @cfg {number[]} [exclude] List of namespace numbers to exclude from the selector */ mw.widgets.NamespaceInputWidget = function MwWidgetsNamespaceInputWidget( config ) { // Configuration initialization @@ -38,10 +39,11 @@ */ mw.widgets.NamespaceInputWidget.prototype.getNamespaceDropdownOptions = function ( config ) { var options, + exclude = config.exclude || [], NS_MAIN = 0; options = $.map( mw.config.get( 'wgFormattedNamespaces' ), function ( name, ns ) { - if ( ns < NS_MAIN ) { + if ( ns < NS_MAIN || exclude.indexOf( Number( ns ) ) !== -1 ) { return null; // skip } ns = String( ns ); diff --git a/resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js b/resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js index cf4d7886ed..c9c9f031ee 100644 --- a/resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js +++ b/resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js @@ -79,6 +79,26 @@ /* Methods */ + /** + * Get the namespace to prepend to titles in suggestions, if any. + * + * @return {number|null} Namespace number + */ + mw.widgets.TitleInputWidget.prototype.getNamespace = function () { + return this.namespace; + }; + + /** + * Set the namespace to prepend to titles in suggestions, if any. + * + * @param {number|null} namespace Namespace number + */ + mw.widgets.TitleInputWidget.prototype.setNamespace = function ( namespace ) { + this.namespace = namespace; + this.lookupCache = {}; + this.closeLookupMenu(); + }; + /** * @inheritdoc */ -- 2.20.1